package com.pkk.cloud.support.admin.service.impl;

import com.pkk.cloud.support.admin.entity.resource.PenguinSysUrlResource;
import com.pkk.cloud.support.admin.mybatis.resource.PenguinSysUrlResourceMapper;
import com.pkk.cloud.support.admin.service.PenguinSysUrlResourceService;
import java.util.HashMap;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * @author peikunkun<br>
 * @version V1.0<br>
 * @Title: 接口与资源的关系业务类<br>
 * @Description: <><br>
 * @date 2020/3/18 下午9:10<br>
 * @URL:[]
 */
@Service
public class PenguinSysUrlResourceServiceImpl implements PenguinSysUrlResourceService {

  @Resource
  private PenguinSysUrlResourceMapper penguinSysUrlResourceMapper;

  /**
   * @Description: 保存接口资源信息
   * @Param: record
   * @return: int
   * @Author: peikunkun
   * @Date: 2020/4/22 0022 下午 3:16
   */
  @Override
  public boolean insertSysUrlResource(PenguinSysUrlResource record) {
    return penguinSysUrlResourceMapper.insertSysUrlResource(record) == 1;
  }

  /**
   * @Description: 删除接口与资源的绑定关系依据资源id
   * @Param: resourceId
   * @return: boolean
   * @Author: peikunkun
   * @Date: 2020/4/22 0022 下午 3:15
   */
  @Override
  public boolean delSysUrlByResourceId(Long resourceId) {
    return penguinSysUrlResourceMapper.delSysUrlByResourceId(resourceId) > 0;
  }

  /**
   * @Description: 批量保存接口与资源的数据关系
   * @Param: resourceId
   * @Param urls
   * @return: void
   * @Author: peikunkun
   * @Date: 2020/4/22 0022 下午 3:20
   */
  @Override
  public int batchSaveSysResourceUrl(Long resourceId, Long[] urls) {
    final HashMap<String, Object> condition = new HashMap<>(3);
    condition.put("resourceId", resourceId);
    condition.put("urls", urls);
    return penguinSysUrlResourceMapper.batchSaveSysResourceUrl(condition);
  }
}
